const db = uniCloud.database()
const dbCmd = db.command;
module.exports = {
	main: async (event) => {
		let {
			res,
			data,
			action
		} = event;
		switch (action) {
			case 'queryOne':
				res = await getPageByUserId(data);
				break;
			default:
				res = {
					code: 402,
					msg: '非法访问'
				}
				break;
		}
		return res;
	}
}

/**
 * 获取页面数据通过用户ID
 */
async function getPageByUserId(data) {
	let res = {}
	res.code = 200
	var result = await db.collection('shop').where({'userId':data.userId}).get()
	res.data = result.data
	return res
}
